package com.cdzy.service.impl;

import com.cdzy.mapper.LendListMapper;
import com.cdzy.pojo.LendList;
import com.cdzy.service.LendListService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 图书借阅表(LendList)表服务实现类
 *
 * @author makejava
 * @since 2025-04-01 10:04:21
 */
@Service("lendListService")
public class LendListServiceImpl implements LendListService {
    @Resource
    private LendListMapper lendListMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param lendId 主键
     * @return 实例对象
     */
    @Override
    public LendList queryById(Integer lendId) {
        return this.lendListMapper.queryById(lendId);
    }


    /**
     * 新增数据
     *
     * @param lendList 实例对象
     * @return 实例对象
     */
    @Override
    public LendList insert(LendList lendList) {
        this.lendListMapper.insert(lendList);
        return lendList;
    }

    /**
     * 修改数据
     *
     * @param lendList 实例对象
     * @return 实例对象
     */
    @Override
    public LendList update(LendList lendList) {
        this.lendListMapper.update(lendList);
        return this.queryById(lendList.getLendId());
    }

    /**
     * 通过主键删除数据
     *
     * @param lendId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer lendId) {
        return this.lendListMapper.deleteById(lendId) > 0;
    }

    /**
     * 查询所有借阅记录
     *
     * @return
     */
    @Override
    public List<LendList> getLendList() {
        List<LendList> lendlist = lendListMapper.getLendList();
        return lendlist;
    }
}
